from django import forms
from .models import MonitoringCategory, MonitoringData

class MonitoringCategoryForm(forms.ModelForm):
    """监测类别表单"""
    class Meta:
        model = MonitoringCategory
        fields = ['name', 'description']
        widgets = {
            'name': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入类别名称'}),
            'description': forms.Textarea(attrs={'class': 'form-control', 'placeholder': '请输入类别描述', 'rows': 3}),
        }

class MonitoringDataForm(forms.ModelForm):
    """监测数据表单"""
    class Meta:
        model = MonitoringData
        fields = ['category', 'location', 'value', 'unit', 'status', 'measured_at', 'notes']
        widgets = {
            'category': forms.Select(attrs={'class': 'form-control'}),
            'location': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入监测地点'}),
            'value': forms.NumberInput(attrs={'class': 'form-control', 'placeholder': '请输入监测值'}),
            'unit': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '请输入单位'}),
            'status': forms.Select(attrs={'class': 'form-control'}),
            'measured_at': forms.DateTimeInput(attrs={'class': 'form-control', 'type': 'datetime-local'}),
            'notes': forms.Textarea(attrs={'class': 'form-control', 'placeholder': '请输入备注', 'rows': 3}),
        } 